import { useUserStore } from "@/store"
const userStore = useUserStore()

// 使用openID作为头像文件名
export const UploadAvatar = async (url) => {
	const openID = await userStore.getOpenID()
	const path = openID || Date.now()
	
	const res = await uniCloud.uploadFile({
		filePath: url,
		cloudPath: `avatar/${path}.png`,
		overwrite: true // 允许覆盖
	})
	
	return res
}